
package com.dg.acb.utils;

import org.json.JSONException;

public class NBResponse extends ParcelableJson{
    private static final String KEY_CODE = "code";
    private static final String KEY_MESSAGE = "message";
    private int mCode;
    private String mMessage;

    public NBResponse(int code, String message) {
        this.mCode = code;
        this.mMessage = message;
    }

    public NBResponse(String json) throws JSONException {
        super(json);
        this.mCode = getInt(KEY_CODE);
        this.mMessage = getString(KEY_MESSAGE);
    }

    public int getCode() {
        return mCode;
    }

    public String getMessage() {
        return mMessage;
    }

    public boolean isOK() {
        return mCode == 0;
    }

    public final static Jsonable.Creator<NBResponse> CREATOR = new Jsonable.Creator<NBResponse>() {
        @Override
        public NBResponse createFromJson(ParcelableJson json) throws JSONException {
            return new NBResponse(json.toString());
        }

        @Override
        public NBResponse[] newArray(int size) {
            return new NBResponse[size];
        }
    };
}
